package com.example.draw;

import javafx.scene.shape.Shape;


/**
 * <p>同类型实例生成</p>
 *
 * @author dc
 * @date 2025-09-29
 **/
public class DrawShapeFactory {
    /**
     * 创建指定类型的实例
     * @param drawShape
     * @return
     */
    public static Shape createShape(DrawShape drawShape) {
        if (drawShape instanceof DrawRectangle) {
            return new DrawRectangle(drawShape.getDrawColor(), drawShape.getDrawThickness());
        } else if (drawShape instanceof DrawCircle) {
            return new DrawCircle(drawShape.getDrawColor(), drawShape.getDrawThickness());
        } else if (drawShape instanceof DrawArrow) {
            return new DrawArrow(drawShape.getDrawColor(), drawShape.getDrawThickness());
        } else {
            return null;
        }
    }
    public static void clearSingleInstances() {
        DrawRectangle.clearSingleInstance();
        DrawCircle.clearSingleInstance();
        DrawArrow.clearSingleInstance();
    }
    
}
